package com.myworkbench.workbench.domain.entity.user;

import com.myworkbench.workbench.domain.ValueObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;

@Embeddable
@Data
@AllArgsConstructor
@NoArgsConstructor
public final  class UserId extends ValueObject<UserId> implements Serializable {

    @Column(name="user_id")
    private Integer id;

    @Override
    public boolean sameValueAs(UserId other) {
        return other != null && this.id.equals(other.id);
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserId other = (UserId) o;

        return sameValueAs(other);
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
    @Override
    public String toString() {
        return String.valueOf(this.id);
    }
}
